package com.zzhua.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("r")
public class RController {
    /**
     * 测试资源1
     *
     * @return
     */
    @GetMapping(value = "r1")
    public String r1() {
        return " 访问资源1";
    }

    /**
     * 测试资源2
     *
     * @return
     */
    @GetMapping(value = "r2")
    public String r2() {
        return " 访问资源2";
    }

    @GetMapping(value = "r3")
    public String r3() {
        return " 访问资源3";
    }

    @RequestMapping("r4")
    @PreAuthorize("hasAnyRole('admin')")
    public String r4() {
        return "访问资源4";
    }
}
